<!-- eslint-disable vue/no-mutating-props -->
<template>
  <a-modal
    v-model:visible="props.visible"
    @ok="handleOk"
    @cancel="emit('update:visible', false)"
  >
    <template #title> 选择模板 </template>
    <a-table
      @select="select"
      :columns="columns"
      :data="props.data"
      :row-selection="rowSelection"
      stripe
    />
  </a-modal>
</template>
<script setup lang="ts">
const props = withDefaults(
  //参数说明
  defineProps<{
    visible: boolean;
    data: any;
  }>(),
  { visible: false }
);
const rowSelection = {
  type: 'radio'
};
const columns = [
  {
    title: '人员信息模板名称',
    dataIndex: 'name'
  },
  {
    title: '模板内容',
    dataIndex: 'remark'
  }
];
const select = (e: (number | string)[]) => {
  id.value = e[0] as number;
};
const id = ref(0);
const handleOk = () => {
  emit('changeId', id.value);
  emit('update:visible', false);
};
const emit = defineEmits(['update:visible', 'changeId']);
</script>
<style lang="less" scoped></style>
